import java.io.*;

public class TheFirstTask {
	private final int MIN_YEAR = 1900;
	private final int MAX_YEAR = 2013;
	private final int MIN_MONTH = 1;
	private final int MAX_MONTH = 12;
	private final int MIN_DAY = 1;
	private final int MAX_DAY_IS_31 = 31;
	private final int MAX_DAY_IS_30 = 30;
	private final int MAX_DAY_IS_29 = 29;
	private final int MAX_DAY_IS_28 = 28;
	
	private int month = 0;
	private int year = 0;
	
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		TheFirstTask task = new TheFirstTask();
		String date = null;
		System.out.println("date example: yyyy-mm-dd\n" +
				"Enter date: ");
		
		while((date = in.readLine()) != "exit") {
			String[] str = date.split("-");
			if(task.verifyYear(str[0]) && task.verifyMonth(str[1]) && task.verifyDay(str[2]))
				System.out.println(date);
		}

	}
	
	private boolean verifyYear(String yearAsStr) {
	
		try {
            year = Integer.parseInt(yearAsStr);
            if(yearAsStr.length() == 4) {
            	if(MIN_YEAR <= year && MAX_YEAR >= year)
            		return true;
            	else
            		System.out.println("This program has limitation by year, " +
            				"where min is " + MIN_YEAR + " and max is " + MAX_YEAR + " year\n" +
                			"Would you enter correct year, please");
            } else
            	System.out.println("Year: Would you enter 4 digits, please");

        } catch (NumberFormatException e) {
        	System.out.println("Year: You should enter digits!");
        	return false;
        	}
		return false;
	}
	
	private boolean verifyMonth(String monthAsStr) {

		try {
			month = Integer.parseInt(monthAsStr);
            if(monthAsStr.length() == 2) {
            	if(MIN_MONTH <= month && MAX_MONTH >= month)
            		return true;
            	else
            		System.out.println("Would you enter correct month, please");
            } else
            	System.out.println("Month: Would you enter 2 digits, please");

        } catch (NumberFormatException e) {
        	System.out.println("Month: You should enter digits!");
        	return false;
        	}
		return false;
	}
	
	private boolean verifyDay(String dayAsStr) {
		int day = 0;
		int maxDay = 0;
		
		try {
			day = Integer.parseInt(dayAsStr);
			maxDay = getMaxDay();
            if(dayAsStr.length() == 2) {
            	if(MIN_DAY <= day && getMaxDay() >= day)
            		return true;
            	else
            		System.out.println("This month has " + maxDay + " days\n" +
            				"Would you enter correct day, please");
            } else
            	System.out.println("Day: Would you enter 2 digits, please");

        } catch (NumberFormatException e) {return false;}
		return false;
	}
	
	private int getMaxDay() {
		int[] MonthsWith31Days = {1,3,5,7,8,10,12};
		int[] MonthsWith30Days = {4,6,9,11};
		int monthOfLeapYear = 2;
		int maxDay = 0;
		
		for(int monthWith31Days : MonthsWith31Days)
			if(monthWith31Days == this.month) return MAX_DAY_IS_31;
		
		for(int monthWith30Days : MonthsWith30Days)
			if(monthWith30Days == this.month) return MAX_DAY_IS_30;
		
		if(monthOfLeapYear == this.month) {
			if(0 == year%2) return MAX_DAY_IS_29;
			else return MAX_DAY_IS_28;
		}
		
		return maxDay;

	}

}
